package com.zyj.springboothapim.service.impl;/**
 * @Date: Created on 2021/1/9  11:47
 */

import com.zyj.springboothapim.bean.Admin;
import com.zyj.springboothapim.mapper.AdminMapper;
import com.zyj.springboothapim.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created on 2021/1/9  11:47
 */
@Service
public class AdminServiceImpl implements AdminService
{
    private AdminMapper adminMapper;

    @Autowired
    public void setAdminMapper(AdminMapper adminMapper){this.adminMapper = adminMapper;}

    //通过工号查询管理员信息
    @Override
    public Admin getAdiminById(Admin admin)
    {
        return adminMapper.getAdiminById(admin);
    }

    //登录验证
    @Override
    public String login(Admin admin)
    {
        //设置返回语句
        String returnStr = "";
        Admin admin1 = adminMapper.getAdiminById(admin);
        if(admin1 == null)
        {
            returnStr = "fail,no AdminId";
        }
        else
        {
            if(admin1.getAdmin_password().equals(admin.getAdmin_password()))
            {
//                密码正确
                returnStr = "success,index.html";
            }
            else
                returnStr = "fail,password error";
        }
        return returnStr;
    }


    @Override
    public List<Admin> selectAdimin()
    {
        return adminMapper.selectAdimin();
    }

    //通过工号修改管理员信息
    @Override
    public void updataAdmin(Admin admin)
    {
        adminMapper.updataAdmin(admin);
    }
}
